{template 'common/header'}
<ul class="nav nav-tabs">
    <li><a href="{php echo $this->createWebUrl('setting')}">基本设置</a></li>
	<li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('nave', array('op' => 'display'))}">管理首页导航</a></li>
    <li {if $operation == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('nave', array('op' => 'post'))}">添加首页导航</a></li>
</ul>
<input type="hidden" name="storeid" value="{$storeid}" />
{if $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
    <div class="panel panel-default">
        <div class="panel-heading">
            区域编辑
        </div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">导航名称</label>
                <div class="col-sm-9">
                    <input type="text" id="linkname" name="linkname"  class="form-control" value="{$nave['name']}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">导航类型</label>
                <div class="col-sm-9">
                    <select id="type" name="type" onchange="return changeType(this.value);" class="form-control">
                        <option value=-1 {if $nave['type']==-1}selected{/if}>自定义</option>
                        <option value=2 {if empty($nave['type']) || $nave['type']==2}selected{/if}>门店列表</option>
                        <option value=3 {if $nave['type']==3}selected{/if}>商品列表</option>
                        <option value=4 {if $nave['type']==4}selected{/if}>我的菜单</option>
                        <option value=5 {if $nave['type']==5}selected{/if}>智能点餐</option>
                        <option value=6 {if $nave['type']==6}selected{/if}>我的订单</option>
                    </select>
                    <span class="help-block">门店为显示顺序排第一的门店</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">导航链接</label>
                <div class="col-sm-9">
                    <input class="form-control" type="text" name="link" id="link" value="{$nave['link']}" />
                    <span class="help-block">指定这个导航的链接目标</span>
                    <div class="alert-block" style="padding:3px 0;"><strong class="text-error">使用模块链接:</strong>
                        <a href="javascript:;" class="icon-external-link" onclick="$('#link').val('mobile.php?act=module&do=wapindex&name=icard&weid={$_W['weid']}');">会员卡</a> &nbsp;
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
                <div class="col-sm-9">
                    <label for="status_1" class="radio-inline"><input autocomplete="off" type="radio" name="status" id="status_1" value="1" {if $nave['status'] == 1 || empty($nave['status'])} checked="checked"{/if} /> 显示</label>
                    <label for="status_0" class="radio-inline"><input autocomplete="off" type="radio" name="status" id="status_0" value="0" {if isset($nave['status']) && $nave['status'] == 0} checked="checked"{/if} /> 隐藏</label>
                    <span class="help-block">设置导航菜单的显示状态</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                <div class="col-sm-9">
                    <input type="text" name="displayorder" class="form-control" value="{$area['displayorder']}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                <div class="col-sm-9">
                    <input name="submit" type="submit" value="提交" class="btn btn-primary span3">
                    <input type="hidden" name="token" value="{$_W['token']}" />
                </div>
            </div>
        </div>
    </div>

	<input type="hidden" name="parentid" value="{$parent['id']}" />
	</form>
</div>
<script language="javascript">
    function changeType(value) {
        var type = value;
        if (type == -1) {
            $("#trlink").show();
        } else {
            $("#trlink").hide();
        }
        var linkname = $("#linkname").val();
        //if (linkname == ''){
            if (type==2) {
                $("#linkname").val('在线点餐');
            }
            if (type==3) {
                $("#linkname").val('商品列表');
            }
            if (type==4) {
                $("#linkname").val('我的菜单');
            }
            if (type==5) {
                $("#linkname").val('智能点餐');
            }
            if (type==6) {
                $("#linkname").val('我的订单');
            }
        //}
    }
    $("trlink").hide();
</script>
{elseif $operation == 'display'}
<div class="main">
    <div class="panel panel-default">
        <div class="panel-body">
            <a class="btn btn-primary" href="{php echo $this->createWebUrl('nave', array('op' => 'display', 'type' => 'default'))}"><i class="fa fa-plus"></i> 快速添加</a>
            <a class="btn btn-primary" href="javascript:location.reload()"><i class="fa fa-refresh"></i>刷新</a>
        </div>
    </div>
    <div class="panel panel-default">
    <form action="" method="post" class="form-horizontal form">

        <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:10%;">显示顺序</th>
                <th style="width:68%;">导航名称</th>
                <th style="width:10%;">状态</th>
                <th style="width:12%;">操作</th>
            </tr>
            </thead>
            <tbody id="level-list">
            {loop $nave $row}
            <tr>
                <td><input type="text" class="form-control" name="displayorder[{$row['id']}]" value="{$row['displayorder']}"></td>
                <td><div class="type-parent">{$row['name']}&nbsp;&nbsp;</div></td>
                <td>
                    {if $row['status']==1}
                    <span class="label label-success">显示</span>
                    {else}
                    <span class="label label-error">隐藏</span>
                    {/if}
                </td>
                <td>
                    <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('nave', array('op' => 'post', 'id' => $row['id']))}" title="编辑"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('nave', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除吗？');return false;" title="删除"><i class="fa fa-times"></i></a>
                </td>
            </tr>
            {/loop}
            <tr>
                <td colspan="4">
                    <input name="submit" type="submit" class="btn btn-primary" value="批量排序">
                    <input type="hidden" name="token" value="{$_W['token']}" />
                </td>
            </tr>
            </tbody>
        </table>
        </div>
    </form>
    </div>
    {$pager}
</div>
{/if}
{template 'common/footer'}